package com.xinqi.modules.file.factory;

import com.xinqi.common.base.error.CommonErrors;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.file.client.SliceImageClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class SliceImageFallbackFactory implements FallbackFactory<SliceImageClient> {
    @Override
    public SliceImageClient create(Throwable throwable) {
        log.error("日志服务调用失败:{}", throwable.getMessage());
        return new SliceImageClient() {
            @Override
            public R<List<String>> addCourseWareQuestion(String ossUrl) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

        };
    }
}
